<?php

/**
 * NOTICE OF LICENSE
 *
 * THIS SOURCE FILE IS PART OF EVEBIT'S PRIVATE PROJECT.
 * 
 * DO NOT USE THIS FILE IN OTHER PLACE.
 *
 * @package   App_Sample
 * @author    Cheng Wei <berlios.o@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 * @copyright Copyright (c) 2008 Evebit Inc. China (http://www.evebit.com)
 */

/**
 * Get Revage rate and get rate count
 * 
 * @package   App_Sample
 * @author    Chang ZhenHua <chang.zhenhua@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 */
class Evebit_View_Helper_GetCitySligtsSubPage extends Zend_View_Helper_Abstract {
		
	/**
	 * Get class
	 * @param string $type
	 * @param int $id
	 * @param int $infoId
	 * @return int
	 */
	function getCitySligtsSubPage($info_id){
		$session = $this->view->getSession();
		//get citys
		$info = new Information_Model_Entity_Information();
		$collection = $info->getCollection();
		$collection->addFieldToFilter('main_table.type','sights');
		$collection->addFieldToFilter('main_table.info_new',1);
		$collection->addFieldToFilter('main_table.enable',1);
		$collection->getSelect()->join(array('sights'=> 'information_sights'),'sights.id = main_table.id');
		$collection->addFieldToFilter('sights.own_city',$info_id);
		$collection->setOrder('main_table.id','DESC');
		$collection->setPageSize(3);
	    $collection->getSelect()->reset(Zend_Db_Select::COLUMNS);
	    $collection->getSelect()->columns("*","sights");
		$collection->getSelect()->columns("*","main_table");
		$sightsItems = $collection->getItems();
		
		$baseUrl = $this->view->baseUrl();
        $imgPath = $baseUrl.'/media/';
        $page='';
        
		foreach ($sightsItems as $item) {
			$page .= '
			    <div class="sight">
				    <a href="'.$baseUrl.'/information/city/show-detail/id/'.$item->getId().'"><img src="'.$imgPath.$item->getImage().'"></a>
				    <div class="word">
				    	<div class="title">
				    		<a href="'.$baseUrl.'/information/city/show-detail/id/'.$item->getId().'">'.Evebit_Controller_Action_Public::substrWithoutBreak($item->getName(), 5).'</a>
				    	</div>
				    	<div class="add">
				    		<a href="#" >Add</a>+
				    	</div>
				    	<div class="clear"></div>
				  		<div class="content">
				  		<p>'.Evebit_Controller_Action_Public::substrWithoutBreak($item->getDescription(), 32).'</p>
				    	</div>				    	
					</div>
					<div class="clear"></div>
				</div>';;
		}
		return $page;
	}	
	
}
